#include <single_thread_scheduler.h>

class Example1 : public Task {
public:
    Example1() {
        period_ms = 50U;
    }
    void period_task() override {
        printf("Example1 before yield timestamp %ld\n", get_timestamp_ms());
        task_yield(2000);
        printf("Example1 after yield timestamp %ld\n", get_timestamp_ms());
    }

};

class Example2 : public Task {
public:
    Example2() {
        period_ms = 200U;
    }
    void period_task() override {
        auto current = get_timestamp_ms();
        printf("Example2 period %ld\n",current - last);
        last = current;
    }
private:
    int64_t last{0};
};

int main() {
    auto scheduler = std::make_unique<SingleThreadScheduler>("target_function");

    scheduler->add_task(std::make_unique<Example1>());
    scheduler->add_task(std::make_unique<Example2>());

    scheduler->init();

    std::this_thread::sleep_for(std::chrono::seconds(3));
}
